<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="css/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="css/mainStyle.css" />
		<!--<link rel="stylesheet" type="text/css" href="css/common.css"/>-->
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-icon iconfont icon-icon mui-pull-left"></a>
			<h1 class="mui-title" id="title">品质生活</h1>
			<a class="mui-icon iconfont icon-youjian mui-pull-right"></a>
		</header>
		<div class="mui-content" id="mainDatas">
			<!-- minnav -->
			<div class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
				<div class="mui-scroll">
					<a class="mui-control-item mui-active" href="mainList1.html">
						<span>推荐</span>
					</a>
					<a class="mui-control-item" href="mainList2.html">
						<span>生鲜食品</span>
					</a>
					<a class="mui-control-item" href="mainList3.html">
						<span>母婴用品</span>
					</a>
					<a class="mui-control-item" href="mainList4.html">
						<span>居家杂货</span>
					</a>
					<a class="mui-control-item" href="mainList5.html">
						<span>特产礼品</span>
					</a>
					<a class="mui-control-item" href="mainList6.html">
						<span>跨境商品</span>
					</a>
					<a class="mui-control-item" href="mainList7.html">
						<span>时尚服饰</span>
					</a>
				</div>
			</div>
		</div>
	</body>
	<script src="js/mui.min.js"></script>
	<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/jquery-1.11.0.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/zepto_1.1.3.js" type="text/javascript" charset="utf-8"></script>
	<script>
		mui.init();
		var subpages = ['mainList1.html', 'mainList2.html', 'mainList3.html', 'mainList4.html', 'mainList5.html', 'mainList6.html', 'mainList7.html'];
		var subpage_style = {
			top: '82px',
			bottom: '0'
		};

		var aniShow = {};

		//创建子页面，首个选项卡页面显示，其它均隐藏；
		mui.plusReady(function() {
			var self = plus.webview.currentWebview();
			for(var i = 0; i < 7; i++) {
				var temp = {};
				var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);
				if(i > 0) {
					sub.hide();
				} else {
					temp[subpages[i]] = "true";
					mui.extend(aniShow, temp);
				}
				self.append(sub);
			}
		});
		//当前激活选项
		var activeTab = subpages[0];
		// var title = document.getElementById("title");
		//选项卡点击事件
		mui('.mui-scroll').on('tap', 'a', function(e) {
			var targetTab = this.getAttribute('href');
			if(targetTab == activeTab) {
				return;
			}
			//更换标题
			//				title.innerHTML = this.querySelector('.mui-tab-label').innerHTML;
			//显示目标选项卡
			//若为iOS平台或非首次显示，则直接显示
			if(mui.os.ios || aniShow[targetTab]) {
				plus.webview.show(targetTab);
			} else {
				//否则，使用fade-in动画，且保存变量
				var temp = {};
				temp[targetTab] = "true";
				mui.extend(aniShow, temp);
				plus.webview.show(targetTab, "fade-in", 300);
			}
			//隐藏当前;
			plus.webview.hide(activeTab);
			//更改当前活跃的选项卡
			activeTab = targetTab;
		});
		//自定义事件，模拟点击“首页选项卡”
		document.addEventListener('gohome', function() {
			var defaultTab = document.getElementById("defaultTab");
			//模拟首页点击
			mui.trigger(defaultTab, 'tap');
			//切换选项卡高亮
			var current = document.querySelector(".mui-bar-tab>.mui-tab-item.mui-active");
			if(defaultTab !== current) {
				current.classList.remove('mui-active');
				defaultTab.classList.add('mui-active');
			}
		});
	</script>

</html>